import  request  from "@/utils/request";
import { ApiRes } from "@/types/data"
import { GoodsInfo } from "@/types/goods"
import { defineStore } from "pinia";

export default defineStore('goods',{
    state(){
        return{
             // 商品详细信息
           info: {} as GoodsInfo,
        }
    },
    actions:{
        async getGoodsList(id : string){
            const res = await request.get<ApiRes<GoodsInfo>>('/goods', {
                params:{
                    id
                }
            })
           this.info = res.data.result  
        },
        clearGoods(){  //切其他页面，在回到当前页面的默认禁用不会丢失
            this.info = {} as GoodsInfo
        }
    },
})